﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;

using App.Helper;
using App.Entity;
using App.Bussiness;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace App.Controllers
{
    /// <summary>
    /// 仓库
    /// </summary>
    [Route("api/[controller]")]
    [Authorize(Roles = "Admin")]
    public class StorageController : Controller
    {
        private StorageBLL BLL = new StorageBLL();
        /// <summary>
        /// 入库
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>

        [HttpPost]
        [Route("In")]
        public JsonResult In([FromBody]Newtonsoft.Json.Linq.JObject para)
        {
            string barcode = para["barcode"].ToString();
            string position = para["position"].ToString();

            string uid = Request.Headers["Uid"].ToString();

            if(BLL.In(barcode,position,uid)){
                return Json(new { recode = 1, msg = "入库成功" });
            }
            return Json(new { recode = 0, msg = "入库失败" });
        }
    }
}
